package com.xls.dormitoryservice.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.xls.dormitoryservice.entity.Building;
import com.xls.dormitoryservice.mapper.BuildingMapper;
import com.xls.dormitoryservice.service.BuildingService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * <p>
 *  服务实现类
 * </p>
 *
 * @author xls
 * @since 2021-03-23
 */
@Service
public class BuildingServiceImpl extends ServiceImpl<BuildingMapper, Building> implements BuildingService {

    @Autowired
    private BuildingMapper buildingMapper;

    @Override
    public List<Building> buildingList() {
        return buildingMapper.selectList(new QueryWrapper<Building>().eq("pid", 0));
    }

    @Override
    public List<Building> floorList() {
        return buildingMapper.selectList(new QueryWrapper<Building>().ne("pid", 0));
    }

    @Override
    public List<Building> floorListById(String id) {
        return buildingMapper.selectList(new QueryWrapper<Building>().eq("pid", id));
    }

    @Override
    public Building building(String id) {
        return buildingMapper.selectById(id);
    }

    @Override
    public Building floor(String id) {
        return buildingMapper.selectById(id);
    }
}
